<?php
namespace catchAdmin\foundation\controller;

use catcher\base\CatchController;
use catcher\base\CatchRequest;
use catcher\CatchResponse;
use app\common\model\Operation as OperationModel;

class Operation extends CatchController
{
    protected $operation;

    public function __construct(OperationModel $operation)
    {
        $this->operation = $operation;
    }

    /**
     * 列表
     *
     * @time 2020年01月09日
     * @param CatchRequest $request
     * @return \think\response\Json
     * @throws \think\db\exception\DbException
     */
    public function index(CatchRequest $request): \think\response\Json
    {
        return CatchResponse::paginate($this->operation->getLists($request->param()));
    }

    /**
     * 保存
     *
     * @time 2020年01月09日
     * @param CatchRequest $request
     * @return \think\response\Json
     */
    public function save(CatchRequest $request): \think\response\Json
    {
        return CatchResponse::success($this->operation->addData($request->param()));
    }

    /**
     * 更新
     *
     * @time 2020年01月09日
     * @param $id
     * @param CatchRequest $request
     * @return \think\response\Json
     */
    public function update($id, CatchRequest $request): \think\response\Json
    {
        return CatchResponse::success($this->operation->saveData($id, $request->param()));
    }

    /**
     * 删除
     *
     * @time 2020年01月09日
     * @param $id
     * @return \think\response\Json
     */
    public function delete($id): \think\response\Json
    {
        return CatchResponse::success($this->operation->destroy($id));
    }

    /**
     * 获取手术数据
     * @return \think\response\Json
     */
    // public function getdisease(): \think\response\Json
    // {
    //     return CatchResponse::success($this->disease->getRows());
    // }
}